<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>ADMIN</title>
    <link rel="stylesheet" th:href="@{/css/admin/base.css}">
    <link rel="stylesheet" th:href="@{/lib/font-awesome/4.7.0/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{/css/admin/app.css}">
</head>

<body>
<div class="app-login">
    <div class="container">
        <div class="header">
            <h1 class="title">后台登录</h1>
        </div>
        <form class="login-form">
            <div class="form-item col">
                <label class="label">账号</label>
                <input type="text" placeholder="请输入账号" name="username" data-name="账号" data-rule="required">
            </div>
            <div class="form-item col">
                <label class="label">密码</label>
                <input type="password" placeholder="请输入密码" name="password" data-name="密码" data-rule="required">
            </div>
            <!--<div class="form-item col">-->
            <!--<label class="label">系统</label>-->
            <!--<input type="password" placeholder="请输入密码" name="password" data-name="密码" data-rule="required">-->
            <!--</div>-->
            <div class="form-msg"></div>
            <div class="form-column z-btn-row">
                <a class="btn-sub z-btn z-btn-l z-primary">登录</a>
                <!--<input class="btn-sub z-btn z-btn-l z-primary" type="submit" value="Submit" value="登录">-->
            </div>
        </form>
    </div>
</div>

<script th:src="@{/lib/jquery.min.js}"></script>
<script th:src="@{/js/form.js}"></script>
<script th:src="@{/js/popup.js}"></script>
<script th:src="@{/js/admin/app.js}"></script>
<script>
    var form = $(".login-form").form({
        msg: function (msg) {
            popup.tips(msg)
        },
        submit: function () {
            var data = {}

            $.each($(".login-form").serializeArray(), function (index, field) {
                data[field.name] = field.value;
            })

            console.log('data');
            console.log(data);

            // $("form").submit(function (e) {
            //     alert("Submitted");
            // });

            App.getData({
                url: App.apiUrlHost + '/formLogin',
                data: {
                    username: $('[name=username]').val(),
                    password: $('[name=password]').val(),
                    platformTag: 'portal',
                    gotoURL: '/login'
                },
                dataType: 'json',
                type: 'post',
                success: function (result) {

                    if (result.code == 0) {

                        nations = result.data;

                        // App.fillForm('.popup-add-acount', result.data);
                        // popup.open('.popup-add-acount');
                        location.href = '/';

                    } else {
                        popup.tipsTop({type: 'error', msg: result.msg})
                    }
                }
            })
        }
    })
</script>
</body>

</html>